Repository navigation
feat(tables): index doc.tables by position - #463
Merged
Merged
Conversation
doc.tables iterated and had a length but could not be indexed, so doc.tables[0] raised TypeError. It now takes an int (negative counts from the end) or a slice, in document order, the same as doc.tables.all[...]; an index out of range raises IndexError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
airmang
commented
Oct 15, 2026
airmang
left a comment
Owner
Author
There was a problem hiding this comment.
df1e58b 검토 완료. __getitem__이 기존 all 목록에 위임하므로 음수·slice·IndexError와 문서 객체의 변경 반영 규약이 유지되는 것을 확인했습니다. 별도 Python 3.12 체크아웃에서 namespace/stable-surface/contract-docs 검사 160개가 통과했습니다. #462 병합 후 실제 최신 main 1ff5265를 로컬 검증 트리에 합친 상태에서도 같은 검사와 HWP 읽기·쓰기 회귀 검사를 포함한 431개가 통과했습니다. 최신 head의 GitHub 검사 13개는 모두 성공했고 미해결 리뷰 스레드가 없습니다. 병합을 막는 결함을 찾지 못했습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
바뀐 점
doc.tables는 반복과len()은 되지만 번호로 꺼낼 수 없어서doc.tables[0]이TypeError를 냈다. python-docx처럼doc.tables[0]로 첫 표를 꺼내는 코드가 그대로 동작하도록 번호와 조각을 받는다.src/hwpx/_document/ns/tables.py:TablesNamespace.__getitem__—int(음수는 끝에서부터)와slice를 문서 순서로 받는다.doc.tables.all[...]와 같고, 범위 밖이면IndexError.int는 표 하나,slice는 표 목록으로 타입을 나눠 적었다(overload).CHANGELOG.md: [Unreleased] 추가에 한 항목.테스트
tests/test_ns_tables.py: 번호·음수·조각이 문서 순서대로 표를 돌려주고 범위 밖이면IndexError인 시험, 번호로 꺼낸 표를 고치면 문서에 남는 시험. 두 시험은 고치기 전 main에서 실패한다.tests/test_stable_surface.py,tests/test_contract_docs_sync.py통과. ruff·mypy·pyright 통과.🤖 Generated with Claude Code